import _ from 'lodash';

export default {

    toRMB(price) {
        if(!price) return '';
            return price.toFixed(1);
    },
  
    formatDate(timeStamp) {
        if(!timeStamp) return '';
        const date   = new Date(timeStamp);
        const year   = date.getFullYear();
        const month  = _.padStart(String(date.getMonth() + 1), 2, '0');
        const day    = _.padStart(String(date.getDate()), 2, '0');
        const hour   = _.padStart(String(date.getHours()), 2, '0');
        const minute = _.padStart(String(date.getMinutes()), 2, '0');
        const second = _.padStart(String(date.getSeconds()), 2, '0');
        return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
    }
}